#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


int main()
{

	int sock = 0;
	int ret = 0;
	char buf[1024] = {0};

	struct sockaddr_in serAddr;
    memset(&serAddr,0,sizeof(serAddr));

	sock = socket(AF_INET,SOCK_DGRAM,0);
	if(sock == -1)
	{
		perror("sock");
		exit(-1);
	}

	serAddr.sin_family = AF_INET;
    serAddr.sin_port = 6868;
    serAddr.sin_addr.s_addr = inet_addr("192.168.0.116");

	char dest[100] = {0};

 while(1)
 {
		printf("please input a string:\n");
		scanf("%s",buf);

		ret = sendto(sock,buf,strlen(buf),0,(struct sockaddr *)&serAddr,sizeof(struct sockaddr));
		if(ret == -1)
		{
			perror("sendto");
		}

		ret = recvfrom(sock,dest,100,0,NULL,NULL);
		if(ret == -1)
		{
			perror("recfrom");
			exit(-1);
		}

		printf("dest is %s\n",dest);
 }

	

	close(sock);

}

